
include(GNUInstallDirs)
include(CheckSymbolExists)
include(CheckLibraryExists)

set(CLOG_SRC
    log.c
    common.c
)



set(CLOG_SOVERSION_FULL "0.0.1")
set(CMAKE_BUILD_TYPE DEBUG)

set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
add_library(srobj OBJECT ${CLOG_SRC})
set_target_properties(srobj PROPERTIES COMPILE_FLAGS " -fPIC")
# set_target_properties(srobj PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -fPIC")

add_library(clog SHARED $<TARGET_OBJECTS:srobj>)
set_target_properties(clog PROPERTIES VERSION ${CLOG_SOVERSION_FULL} SOVERSION ${CLOG_SOVERSION})


option (CLOG_SYSLOG 
        "Enabled output log to syslog." ON)


# generate files
configure_file("${PROJECT_SOURCE_DIR}/clog/common.h.in" "${PROJECT_BINARY_DIR}/common.h" ESCAPE_QUOTES @ONLY)


# configure_file("${PROJECT_SOURCE_DIR}/src/common.h.in" "${PROJECT_BINARY_DIR}/common.h" ESCAPE_QUOTES @ONLY)
# configure_file("${PROJECT_SOURCE_DIR}/src/executables/bin_common.h.in" "${PROJECT_BINARY_DIR}/bin_common.h" ESCAPE_QUOTES @ONLY)
# configure_file("${PROJECT_SOURCE_DIR}/sysrepo.pc.in" "${PROJECT_BINARY_DIR}/sysrepo.pc" @ONLY)

# include repository files with highest priority
include_directories("${PROJECT_SOURCE_DIR}/clog")
include_directories(${PROJECT_BINARY_DIR})


# installation
install(TARGETS clog DESTINATION ${CMAKE_INSTALL_LIBDIR})

# public headers
set(LIB_HEADERS
    log.h
    ${PROJECT_BINARY_DIR}/common.h
    types.h)
install(FILES ${LIB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/clog)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libclog.pc DESTINATION /usr/lib/pkgconfig)

